plot_fect <- function(fect.model,
                      xmin=-8, xmax=4, ymin=-5, ymax=10,
                      xtitle = "Time since the Shale Shock Began",
                      equiv.p, equiv.p.x = -4, equiv.p.y=5){
  df <- plot(fect.model)$data
  p.att <-
    df %>%
    ggplot(aes(x=time,y=ATT,ymin=CI.lower,ymax=CI.upper)) +
    geom_hline(yintercept = 0, color = "grey") +
    geom_vline(xintercept = .5, color = "grey") +
    geom_errorbar(width=0,linewidth=1.25) +
    geom_point(size=3) +
    theme_bw(base_size=14) +
    scale_y_continuous(limits = c(ymin, ymax)) +
    scale_x_continuous(breaks = seq(xmin, xmax, 1)) +
    labs(x=xtitle, y = "Effect on Republican Vote Share (pp)", title = "Estimated ATT") +
    theme(plot.title = element_text(hjust=.5),
          panel.grid = element_blank())
  #get equiv plot data
  effectplot <- plot(fect.model, type = "equiv")$data
  minequiv <- effectplot$bound[1]
  equivrange <- effectplot$bound[length(effectplot$bound)]
  p.equiv <-
    df %>%
    dplyr::filter(time <= 0) %>%
    ggplot(aes(x=time,y=ATT,ymin=CI.lower.90,ymax=CI.upper.90)) +
    geom_hline(yintercept=minequiv,color="black", lty="dashed") +
    geom_hline(yintercept=-minequiv,color="black", lty="dashed") +
    geom_hline(yintercept=equivrange,color="red",lty="dashed") +
    geom_hline(yintercept=-equivrange,color="red", lty="dashed") +
    geom_hline(yintercept = 0, color = "grey") +
    geom_vline(xintercept = .5, color = "grey") +
    geom_errorbar(width=0,size=1.25) +
    geom_point(size=3) +
    theme_bw(base_size=14) +
    labs(x=xtitle, y = "Effect on Republican Vote Share (pp)",
         title = "Equivalence Test", lty="",color="") +
    theme(plot.title = element_text(hjust=.5)) +
    scale_y_continuous(limits = c(ymin, ymax)) +
    scale_x_continuous(breaks = seq(xmin, xmax, 1)) +
    annotate("text", label = equiv.p, x=equiv.p.x,y=equiv.p.y) +
    scale_color_manual(values=c("red","black")) +
    theme(
      panel.grid = element_blank(),
      legend.position = c(0.8, 0.15),
      legend.background = element_rect(fill='transparent'),
      legend.box.background = element_rect(fill='transparent',color="transparent")
    )
  p.out <- gridExtra::grid.arrange(p.att, p.equiv, ncol = 2)
  return(p.out)
}
